//
//  UIBarButtonItem+item.m
//  BaiSi
//
//  Created by warm on 17/8/12.
//  Copyright © 2017年 hp. All rights reserved.
//

#import "UIBarButtonItem+item.h"

@implementation UIBarButtonItem (item)

+(UIBarButtonItem *)itemWithimage:(UIImage *)image highImage:(UIImage *)highImage target:(id)target action:(SEL)action
{

    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
    
    [btn setImage:image forState:UIControlStateNormal];
    [btn setImage:highImage forState:UIControlStateHighlighted];
    [btn sizeToFit];
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];

    
    UIView *containView=[[UIView alloc]initWithFrame:btn.bounds];
    [containView addSubview:btn];
    return  [[UIBarButtonItem alloc]initWithCustomView:containView];
    
   


}
+(UIBarButtonItem *)itemWithimage:(UIImage *)image selImage:(UIImage *)selImage target:(id)target action:(SEL)action
{

    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];
    
    [btn setImage:image forState:UIControlStateNormal];
    [btn setImage:selImage forState:UIControlStateSelected];
    
    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];


    UIView *containVIew=[[UIView alloc]initWithFrame:btn.bounds];
    
    [containVIew addSubview:btn];
    return  [[UIBarButtonItem alloc]initWithCustomView:containVIew];



}

@end
